package com.snopy.lambda;

import com.snopy.pojo.Person;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * @author snopy
 * @version 1.0.0
 * @classname DemoMethodReferences
 * @description
 * @email 77912204@qq.com
 * @date 2022/07/22 17:04
 */
public class DemoMethodReferences {

    public static void main(String[] args) {
        List<Person> roster = Person.createPerson(10);
        roster.forEach(Person::printPerson);
        System.out.println("sorted---------------------------");
        //Person[] rosterAsArray = roster.toArray(new Person[roster.size()]);
        class RosterComparator implements Comparator<Person>{
            @Override
            public int compare(Person o1, Person o2) {
                return o2.getBirthday().compareTo(o1.getBirthday());
            }
        }
        //roster.sort(new RosterComparator());
        //Arrays.sort(rosterAsArray,new RosterComparator());
        roster.forEach(Person::printPerson);
        //reference a static method

    }

}
